<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>{$title}</title>
<link rel="stylesheet" href="Res/boot/css/bootstrap.min.css" type="text/css" media="screen" />
<script type="text/javascript" src="Res/js/jquery-1.11.3.min.js"></script>
<script type="text/javascript" src="Res/js/jquery.cookie.js"></script>
<link rel="stylesheet" href="Res/css/global.css" type="text/css" />
</head>

<body>
<div class="container-fluid">
    <div class="row-fluid">
        <div class="span12 panel panel-info">  
            <span class="cp_title">{$title}</span>
            <div class="add_cp">
                    <a href="index.php?c={$class}&m=view">+返回{$title}列表</a>
            </div>        
            <div class="table_con" style="margin: 0 auto;text-align: center;">
                <form class="form-horizontal" role="form" id="myform" action="index.php?c={$class}&m=new_create" method="post">
                <div class="form-group">
                    <label class="col-sm-2 control-label">模块名称：</label>
                    <div class="col-sm-5">
                        <select class="form-control" id="mid" name="mid">
                            <option value="0">选择模块</option>
                            {foreach from=$module item=row}
                            {if $cookie.mid eq $row.mid}
                            <option value="{$row.mid}" selected="true">{$row.mname}</option>
                            {else}
                            <option value="{$row.mid}">{$row.mname}</option>
                            {/if}
                            {/foreach}
                        </select>
                    </div>
                </div>    
                <div class="form-group">
                    <label class="col-sm-2 control-label">标题URL：</label>
                    <div class="col-sm-5">
                        <input type="text"  value="{$cookie.url}" autofocus="autofocus" required="required" 
                               class="form-control" autocomplete="on" id="url" name="url" placeholder="标题URL" />
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">分析：</label>
                    <div class="col-sm-5">
                        <input type="button" class="btn btn-primary form-control" id="btn_fx_tianya" value="天涯分析"/>
                    </div>                    
                </div>    
                <div class="form-group">
                    <label class="col-sm-2 control-label">标题名称：</label>
                    <div class="col-sm-5"> 
                        <input type="text" class="form-control" readonly="true" id="tname" name="tname" />
                    </div>
                </div>
               <div class="form-group">
                    <label class="col-sm-2 control-label">作者名称：</label>
                    <div class="col-sm-5">
                        <input type="text" class="form-control" readonly="true" id="author" name="author" />
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">作者ID：</label>
                    <div class="col-sm-5">
                        <input type="text" class="form-control" readonly="true" id="uid" name="uid" />
                    </div>
                </div>    
                <div class="form-group">
                    <label class="col-sm-2 control-label">发表时间：</label>
                    <div class="col-sm-5">
                        <input type="text" class="form-control" readonly="true" id="stime" name="stime" />
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-offset-2 col-sm-5">
                        <input type="hidden" value="{$token}" name="token" />
                        <button type="submit" id="btn_add" class="btn btn-primary btn-lg btn-block">添加</button>            
                    </div>
                </div>
                </form>
            </div>
        </div>
    </div>
</div>
{literal}
<script>    
$(function(){
    var cookie_tag = "title_url";
    $("#url").val($.cookie(cookie_tag));
    $("#btn_fx_tianya").click(function(){
        var url = $("#url").val();        
        if(url !== '') {
            var btn_txt = $(this).val();
            $("#btn_fx_tianya").val("分析中...").attr("disabled", true);            
            var date = new Date();
            $.cookie(cookie_tag, url, date.getTime() + (10 * 60 * 1000));
            var url_str = 'index.php?c=storytitle&m=fx_tianya';
            var params = new Object();
            params.url = url;
            $.post(url_str, params, function(data){
                if(data.status === 0) {
                    in_content(data.msg.name, data.msg.author, data.msg.uid, data.msg.stime);
                    $("#btn_fx_tianya").val(btn_txt).attr("disabled", false);
                } else {
                    window.alert(data.msg);
                }
            }, 'json');
        } else {
            $("#url").attr("placeholder", '请输入URL');
        }
    });
});
function in_content(name, author, uid, stime){
    $("#tname").val(name);
    $("#author").val(author);
    $("#uid").val(uid);
    $("#stime").val(stime);
}
</script>
{/literal}
</script>
</body>
</html>
